package com.xnyzc.lhy.mis.controller.cmsapi.activity;


import com.xnyzc.lhy.common.entity.ActivityRv;
import com.xnyzc.lhy.common.exception.ActivityException;
import com.xnyzc.lhy.common.penum.activity.ActivityErrorCode;
import com.xnyzc.lhy.mis.entity.result.activity.ActivityRewardResult;
import com.xnyzc.lhy.mis.service.activity.IOaSysActivityRewardService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 活动结果 前端控制器
 * </p>
 *
 * @author haoyfa
 * @since 2019-12-16
 */
@RestController
@RequestMapping("/activity/activityReward")
@Slf4j
public class OaSysActivityRewardController {

    @Autowired
    private IOaSysActivityRewardService iOaSysActivityRewardService;

    /**
     * 查询活动信息（根据活动定义ID）
     *
     * @return
     */
    @ApiOperation(value = "查询活动信息（根据活动定义ID）", notes = "查询活动信息（根据活动定义ID）")
    @GetMapping(value = "/queryActivityRewardList")
    public ActivityRv queryActivityRewardList(@RequestParam("periodId") String periodId) {
        try {
            List<ActivityRewardResult> activityRewardResultList = iOaSysActivityRewardService.queryActivityRewardResultList(periodId);
            return ActivityRv.wrapSuccess(activityRewardResultList);
        }
        catch (ActivityException ae){
            log.error("查询活动信息（根据活动定义ID）：" + ae.getErrno().getDesc());
            return ActivityRv.wrapErrorCode(ae.getErrno());
        }
        catch (Exception ex){
            log.error("查询活动信息（根据活动定义ID）：" + ActivityErrorCode.unKnow.getDesc());
            return ActivityRv.wrapErrorCode(ActivityErrorCode.unKnow);
        }
    }
}
